package other_其他模式.transfer_object_pattern_传输对象模式;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: hihi
 * @Date: 2020/07/10/14:32
 * @Description:
 */
public class StudentBO {

	private List<Student> students = new ArrayList<>();

	public StudentBO() {
		students.add(new Student(0, "zhangsan"));
		students.add(new Student(1, "lisi"));
		students.add(new Student(2, "wangwu"));
	}

	public void deleteStudent(Student student) {
		students.remove(student.getId());
	}

	public List<Student> getStudents() {
		return students;
	}

	public Student getById(int id) {
		return students.get(id);
	}

	public void updateStudent(Student student) {
		students.get(student.getId()).setName(student.getName());
		System.out.println("Student: Roll No " + student.getId() + ", updated in the database");
	}
}
